package com.itany.corejava.code06_数组;

/**
 * @author MissChen
 * @version 1.0
 * @date 2023 年10月27日 10:37
 */
public class Test04_增强for循环 {
    public static void  main(String[] args){
        String[] names={"admin","lucy","cici","alice"};
        for(int i=0;i<names.length;i++){
            System.out.print(names[i]+" ");
        }
        System.out.println();
        //增强for循环来循环变量,无法获取到数组下标的
        // for(数据类型 变量名:数组){
        //
        // }
        for(String name:names){
            System.out.print(name+"\t");
        }

        String[] names2={"admin","lucy","cici","alice"};

        //java.lang.ArrayIndexOutOfBoundsException:数组下标越界
        System.out.println(names2[4]);
    }
}
